package com.gutsyzhan.dynamicdatasourcespringbootstarter.provider;

import com.gutsyzhan.dynamicdatasourcespringbootstarter.properties.DataSourceProperty;

import javax.sql.DataSource;
import java.util.Map;

/**
 * 从YAML文件中读取数据源属性，进行加载
 */
public class YamlDynamicDataSourceProvider extends AbstractDynamicDataSourceProvider{
    private final Map<String, DataSourceProperty> propertyMap;

    public YamlDynamicDataSourceProvider(Map<String, DataSourceProperty> propertyMap){
        this.propertyMap = propertyMap;
    }

    @Override
    public Map<String, DataSource> loadDataSource() {
        return createDataSourceMap(this.propertyMap);
    }
}
